Skip to content

Conversation

@wilbertbw
Copy link

Addressed Issue #149164: Simplify autodiff handling of dependencies (rlib)

Updated adjust_activity_to_abi to accept a function pointer type instead of Instance and use fn_abi_of_fn_ptr instead of fn_abi_of_instance.

Also updated the arguments passed into the adjust_activity_to_abi call in compiler/rustc_codegen_llvm/src/intrinsic.rs.

@rustbot
Copy link
Collaborator

rustbot commented Nov 27, 2025

Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs

cc @ZuseZ4

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 27, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

…ion in /compiler/rustc_codegen_llvm/src/intrinsic.rs
@rust-log-analyzer

This comment has been minimized.

@wilbertbw wilbertbw marked this pull request as draft November 27, 2025 06:45
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2025
@wilbertbw wilbertbw marked this pull request as ready for review November 27, 2025 08:25
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 27, 2025
@ZuseZ4
Copy link
Member

ZuseZ4 commented Nov 27, 2025

If this code works, then you should also be able to remove some more code, as per:

Is rustc_monomorphize::collector::autodiff::collect_autodiff_fn even necessary in the first place. The catch_unwind intrinsic also needs the function arguments to be codegened, yet it doesn't have any special casing in the monomorphization collector. Enzyme needs the function to differentiate to be in the same module, but I would expect fat LTO to run early enough to already cause that to happen. If you remove collect_autodiff_fn then I would assume this special case in cross_crate_inlineable isn't necessary either.

I marked the locations as fixme in https://github.com/rust-lang/rust/pull/149033/files

Also, did you verify that the test cases still pass with your changes? Here are the instructions to do so:
https://rustc-dev-guide.rust-lang.org/autodiff/installation.html#build-instructions

r? me

@rustbot rustbot assigned ZuseZ4 and unassigned davidtwco Nov 27, 2025
@wilbertbw wilbertbw marked this pull request as draft November 27, 2025 15:55
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2025
@wilbertbw
Copy link
Author

Sounds good, I will update the code and ensure it will pass the test cases.

@wilbertbw
Copy link
Author

Hi there, I checked out this commit, which is the last commit before I made the commits in this PR.

I tried to follow the build steps in this link you gave: https://rustc-dev-guide.rust-lang.org/autodiff/installation.html#build-instructions, but the build fails with errors due to being unable to compile core and rustc-demangle. Both errors are caused by "process didn't exit successfully" and have this at the end: exit code: 0xc0000005, STATUS_ACCESS_VIOLATION.

Could you please help with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants